package mysql

import "gorm.io/gorm"

type Order struct {
	gorm.Model
	UserId   int     `gorm:"type:int;not null;comment:用户id"`
	OrderNum string  `gorm:"type:varchar(50);not null;comment:订单号"`
	PayTime  string  `gorm:"type:varchar(200);not null;comment:下单时间"`
	PayType  int     `gorm:"type:tinyint;not null;comment:订单状态:1.待支付 2.已支付 3.已退款 4.已完成"`
	PayPrice float64 `gorm:"type:decimal(10,2);not null;comment:订单金额"`
}

type OrderGood struct {
	gorm.Model
	OrderId   int     `gorm:"type:int;not null;comment:订单id"`
	GoodId    int     `gorm:"type:int;not null;comment:商品id"`
	GoodName  string  `gorm:"type:varchar(15);not null;comment:商品名称"`
	GoodPrice float64 `gorm:"type:decimal(10,2);not null;comment:商品单价"`
	Num       int     `gorm:"type:int;not null;comment:订单数量"`
}

func (o *Order) Create() error {
	return DB.Create(&o).Error
}

func (og *OrderGood) Create() error {
	return DB.Create(&og).Error
}
